<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        canvas {
            border: 1px solid;
        }
    </style>
</head>

<body>
    <canvas width="400" height="400"></canvas>

    <script>
        const cvs = document.querySelector('canvas');// 获取 canvas 元素
        let ctx = cvs.getContext("2d"); // 获取画笔


        let i = 0;

        setInterval(function () {
            ctx.save();
            ctx.clearRect(0, 0, cvs.width, cvs.height); // 擦除
            ctx.translate(200, 200); // 平移到中心点
            ctx.rotate(Math.PI / 180 * i++); // 旋转

            //------
            // 整圆
            ctx.arc(0, 0, 200, 0, Math.PI * 2);
            ctx.stroke();

            // 大黑半圆
            ctx.beginPath();
            ctx.arc(0, 0, 200, 0, Math.PI);
            ctx.fill();
            //------

            ctx.restore();
        }, 200);

    </script>
</body>

</html>